package com.penngo.gui.dfdiff.view;

import com.penngo.gui.dfdiff.utils.LogUtils;
import java.util.List;
import java.util.logging.Logger;

public class FolderNode extends DataNode<FolderNode>{
    private final static Logger log = LogUtils.getLogger(FolderNode.class);
    // 是否遍历目录
    public enum CheckType {
        YES, NOT, UNCHECKED
    }
    public enum ExistType {
        YES, NOT, UNCHECKED
    }
    private String name;
    private long size;
    private long updateTime;
    private String path;
    private boolean directory;
    private CheckType left;  // 左边遍历
    private CheckType right; // 右边遍历
    private ExistType leftExist;  // 左边遍历
    private ExistType rightExist; // 右边遍历
    private boolean isSame = false; // Adler32是否相等
    private String leftCode = "";
    private String rightCode = "";

    private List<FolderNode> children = null;//new ArrayList<>();

    public FolderNode(){

    }

    public FolderNode(String name, long size, Long updateTime) {
        this.name = name;
        this.size = size;
        this.updateTime = updateTime;
        this.directory = false;
        this.left = CheckType.UNCHECKED;
        this.right = CheckType.UNCHECKED;
        this.leftExist = ExistType.UNCHECKED;
        this.rightExist = ExistType.UNCHECKED;
    }



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

//    public List<FolderNode> getChildren() {
//        if(children == null){
//            children = new ArrayList<>();
//        }
//        return children;
//    }
//
//    public void setChildren(List<FolderNode> children) {
//        this.children = children;
//    }

    public boolean isDirectory() {
        return directory;
    }

    public void setDirectory(boolean directory) {
        this.directory = directory;
    }

    public CheckType getLeft() {
        return left;
    }

    public void setLeft(CheckType left) {
        this.left = left;
    }

    public CheckType getRight() {
        return right;
    }

    public void setRight(CheckType right) {
        this.right = right;
    }

    public boolean isSame() {
        return isSame;
    }

    public void setSame(boolean same) {
        isSame = same;
    }

    public String getLeftCode() {
        return leftCode;
    }

    public void setLeftCode(String leftCode) {
        this.leftCode = leftCode;
    }

    public String getRightCode() {
        return rightCode;
    }

    public void setRightCode(String rightCode) {
        this.rightCode = rightCode;
    }

    public ExistType getLeftExist() {
        return leftExist;
    }

    public void setLeftExist(ExistType leftExist) {
        this.leftExist = leftExist;
    }

    public ExistType getRightExist() {
        return rightExist;
    }

    public void setRightExist(ExistType rightExist) {
        this.rightExist = rightExist;
    }

    public String toString(){
        if(left == CheckType.YES && leftExist == ExistType.YES || right == CheckType.YES && rightExist == ExistType.YES){
            return name;
        }
        else return "";
    }

    public String toString2() {
        return "FolderTreeNode{" +
                "name='" + name + '\'' +
                ", size=" + size +
                ", updateTime=" + updateTime +
                ", path='" + path + '\'' +
                ", directory=" + directory +
                ", left=" + left +
                ", right=" + right +
                ", leftExist=" + leftExist +
                ", rightExist=" + rightExist +
                ", isSame=" + isSame +
                ", leftCode='" + leftCode + '\'' +
                ", rightCode='" + rightCode + '\'' +
                ", children=" + children +
                '}';
    }


    public static void main(String[] args) {
        String a = "aa";
        String b = "bb";
        System.out.println(a.compareTo(b));
        System.out.println(b.compareTo(a));
    }
}
